<?php
/*
 * Krpano100 企业后台常用方法
 * ============================================================================
 * 技术支持：2015-2099 成都世纪川翔科技有限公司
 * 官网地址: http://www.krpano100.com
 * ----------------------------------------------------------------------------
 * $Author: yuanjiang 932625974#qq.com $
 * $Id: lib_main.php 28028 2016-02-19Z yuanjiang $
*/
if(!defined('IN_T')){
	die('hacking attempt');
}

/*
 *获取当前商户所有员工id
 */
function get_ids($id){
	$user = $GLOBALS['Db']->query("select id,p_id from ".$GLOBALS['Base']->table('company')." where id=".$id."","Row");
	// var_dump($user);
	if($user['p_id']>0){
	  $user_id = $user['p_id'];
	}else{
	  $user_id = $user['id'];
	}
	$arr = $GLOBALS['Db']->query("select id from ".$GLOBALS['Base']->table('company')." where p_id=".$user_id."");
	foreach($arr as $k=>$v){
	  $ids .=$v['id'].',';
	}
	$ids.=$user_id;
	return $ids;
}

/*
 * 获取当前用户的company_id
 * @return company_id=0，则是管理员；company_id=p_id，则是员工；company_id=company_id，则是企业管理账号
 */
function get_company_id(){
	$c_id = $GLOBALS['company']['is_admin'] ? 0 : ($GLOBALS['company']['p_id'] ? $GLOBALS['company']['p_id'] : $GLOBALS['company']['id']);
	return $c_id;
}

?>